﻿<Window x:Class="TronAdventure.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TronAdventure"
        xmlns:sensorWpf="clr-namespace:SensorWpf;assembly=SensorWpf"
    Title="" Width="1020" Height="700"
    KeyDown="OnKeyDown"
    Loaded="OnLoaded"
    >
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources3D.xaml" />
        <ResourceDictionary>
          <MeshGeometry3D x:Key="wallGeometry"
            TriangleIndices="0,1,2 2,3,0 4,5,6 6,7,4 8,9,10 10,11,8 12,13,14 14,15,12 16,17,18 18,19,16 20,21,22 22,23,20 "
            Normals="0,0,-1 0,0,-1 0,0,-1 0,0,-1 0,0,1 0,0,1 0,0,1 0,0,1 0,-1,0 0,-1,0 0,-1,0 0,-1,0 1,0,0 1,0,0 1,0,0 1,0,0 0,1,0 0,1,0 0,1,0 0,1,0 -1,0,0 -1,0,0 -1,0,0 -1,0,0 "
            Positions="-0.5,-0.5,-0.5 -0.5,0.5,-0.5 0.5,0.5,-0.5 0.5,-0.5,-0.5 -0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,-0.5 0.5,-0.5,-0.5 0.5,-0.5,0.5 -0.5,-0.5,0.5 0.5,-0.5,-0.5 0.5,0.5,-0.5 0.5,0.5,0.5 0.5,-0.5,0.5 0.5,0.5,-0.5 -0.5,0.5,-0.5 -0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,-0.5 -0.5,-0.5,-0.5 -0.5,-0.5,0.5 -0.5,0.5,0.5"
        />
          <GeometryModel3D x:Key="floorModel" Geometry="{StaticResource wallGeometry}">
            <GeometryModel3D.Material>
              <DiffuseMaterial>
                <DiffuseMaterial.Brush>
                  <SolidColorBrush Color="LightGray"/>
                </DiffuseMaterial.Brush>
              </DiffuseMaterial>
            </GeometryModel3D.Material>
          </GeometryModel3D>
          <GeometryModel3D x:Key="gridModel" Geometry="{StaticResource wallGeometry}">
            <GeometryModel3D.Material>
              <DiffuseMaterial>
                <DiffuseMaterial.Brush>
                  <SolidColorBrush Color="Green"/>
                </DiffuseMaterial.Brush>
              </DiffuseMaterial>
            </GeometryModel3D.Material>
          </GeometryModel3D>
          <GeometryModel3D x:Key="wallModel0" Geometry="{StaticResource wallGeometry}">
            <GeometryModel3D.Material>
              <DiffuseMaterial>
                <DiffuseMaterial.Brush>
                  <SolidColorBrush Color="Purple"/>
                </DiffuseMaterial.Brush>
              </DiffuseMaterial>
            </GeometryModel3D.Material>
          </GeometryModel3D>
          <GeometryModel3D x:Key="wallModel1" Geometry="{StaticResource wallGeometry}">
            <GeometryModel3D.Material>
              <DiffuseMaterial>
                <DiffuseMaterial.Brush>
                  <SolidColorBrush Color="Navy"/>
                </DiffuseMaterial.Brush>
              </DiffuseMaterial>
            </GeometryModel3D.Material>
          </GeometryModel3D>
          <ModelVisual3D x:Key="wallVisual" Content="{StaticResource wallModel0}">
            <ModelVisual3D.Transform>
              <Transform3DGroup>
                <ScaleTransform3D ScaleX="0.01" ScaleY="0.1"  ScaleZ="0.1" />
                <RotateTransform3D>
                  <RotateTransform3D.Rotation>
                    <AxisAngleRotation3D Axis="0 1 0" Angle="0" />
                  </RotateTransform3D.Rotation>
                </RotateTransform3D>
                <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" />
              </Transform3DGroup>
            </ModelVisual3D.Transform>
          </ModelVisual3D>
        </ResourceDictionary>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>

  <Grid>
    <DockPanel>
      <Menu DockPanel.Dock="Top">
        <MenuItem Header="Game">
          <MenuItem Header="Go" Click="StartGameClick" />
          <MenuItem Header="Test" Click="TestClick" />
        </MenuItem>
      </Menu>
            <Grid DockPanel.Dock="Left" HorizontalAlignment="Left" VerticalAlignment="Stretch" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <sensorWpf:SensorDebug ShowZbar="False" x:Name="ucDebug" Grid.Row="0"/>
                
                <ProgressBar x:Name="pgbSpeed" Orientation="Vertical" Margin="20,20,20,20" Value="0" Minimum="0" Maximum="100" Grid.Row="1" VerticalAlignment="Stretch"/>
                <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <StackPanel.BitmapEffect>
                        <DropShadowBitmapEffect Color="Black" Opacity="0.75" Direction="315" ShadowDepth="4" Noise="0.01"/>
                    </StackPanel.BitmapEffect>
                    <Grid>
                    
                        <TextBlock Text="Speed" FontSize="20" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" Margin="1,1,-1,-1"/>
                        <TextBlock Text="Speed" FontSize="20" HorizontalAlignment="Center" FontWeight="Bold" Opacity="0.75"/>
                    </Grid>
                    <Grid>

                        <TextBlock Text="boost" FontSize="20" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" Margin="1,1,-1,-1"/>
                        <TextBlock Text="boost" FontSize="20" HorizontalAlignment="Center" FontWeight="Bold" Opacity="0.75"/>
                    </Grid>
                    <Grid>
                        <TextBlock Text="{Binding ElementName=pgbSpeed,Path=Value}" FontSize="40" HorizontalAlignment="Center" Foreground="White" FontWeight="Bold" Margin="1,1,-1,-1"/>
                        <TextBlock Text="{Binding ElementName=pgbSpeed,Path=Value}" FontSize="40" HorizontalAlignment="Center" FontWeight="Bold" Opacity="0.75"/>
                    </Grid>
                </StackPanel>
            </Grid>
            
            <Viewbox>
          <Grid x:Name="grid1" Width="300" Height="300">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="50*" />
              <ColumnDefinition Width="50*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="50*" />
              <RowDefinition Height="50*" />
            </Grid.RowDefinitions>
            <Border Grid.Column="0" Grid.ColumnSpan="2"  Grid.Row="0" Grid.RowSpan="2"
                    BorderBrush="Black" BorderThickness="1" Margin="5"
                    >
              <Viewport3D x:Name="myViewport3D" Width="300" Height="300">
                <Viewport3D.Camera>
                  <PerspectiveCamera x:Name="camera" 
                    Position="0 0 0" NearPlaneDistance="0.01" FarPlaneDistance="50"
                    FieldOfView="60" LookDirection="0 1 0" UpDirection="0 0 1">
                    <PerspectiveCamera.Transform>
                      <Transform3DGroup>
                        <RotateTransform3D>
                          <RotateTransform3D.Rotation>
                            <AxisAngleRotation3D Axis="1 0 0" Angle="-5"/>
                          </RotateTransform3D.Rotation>
                        </RotateTransform3D>
                        <RotateTransform3D>
                          <RotateTransform3D.Rotation>
                            <AxisAngleRotation3D Axis="0 0 1" Angle="0"/>
                          </RotateTransform3D.Rotation>
                        </RotateTransform3D>
                        <TranslateTransform3D OffsetX="0.5" OffsetY="-0.5" OffsetZ="0.5" />
                      </Transform3DGroup>
                    </PerspectiveCamera.Transform>
                  </PerspectiveCamera>
                </Viewport3D.Camera>
                <ModelVisual3D>
                  <ModelVisual3D.Transform>
                    <Transform3DGroup>
                      <ScaleTransform3D ScaleX="1" ScaleY="1"  ScaleZ="1" />
                      <RotateTransform3D>
                        <RotateTransform3D.Rotation>
                          <AxisAngleRotation3D Axis="0 1 0" Angle="0" />
                        </RotateTransform3D.Rotation>
                      </RotateTransform3D>
                      <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0" />
                    </Transform3DGroup>
                  </ModelVisual3D.Transform>

                  <ModelVisual3D.Content>
                    <Model3DGroup>
                      <AmbientLight Color="#333333" />
                      <DirectionalLight Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
                      <DirectionalLight Color="#FFFFFF" Direction="0.612372,-0.5,-0.612372" />
                    </Model3DGroup>
                  </ModelVisual3D.Content>

                  <ModelVisual3D x:Name="modelVisual3DRoot">
                  </ModelVisual3D>

                </ModelVisual3D>
              </Viewport3D>
            </Border>
            <!--Grid.Column="1" Grid.Row="0"-->
            <Viewbox
              Grid.Column="1" Grid.Row="0"
              >
              <Canvas x:Name="canvas" Width="300" Height="300">
                <Canvas.RenderTransform>
                  <TransformGroup>
                    <RotateTransform x:Name="canvasRotation" CenterX="150" CenterY="150" />
                    <ScaleTransform CenterX="150" CenterY="150" ScaleX="0.7" ScaleY="0.7" />
                  </TransformGroup>
                </Canvas.RenderTransform>
              </Canvas>
            </Viewbox>
          </Grid>
      </Viewbox>
    </DockPanel>
  </Grid>
</Window>
